package com.skyyan.netty.jjf.server;

import io.netty.channel.Channel;

/**
 * 客户端信息类
 * 用于存储已连接客户端的相关信息
 */
public class ClientInfo {
    // 客户端唯一标识（设备注册号）
    private final String clientId;
    
    // 客户端连接通道
    private final Channel channel;
    
    // 客户端注册时间
    private final long registerTime;
    
    // 最后活跃时间
    private volatile long lastActiveTime;

    public ClientInfo(String clientId, Channel channel) {
        this.clientId = clientId;
        this.channel = channel;
        this.registerTime = System.currentTimeMillis();
        this.lastActiveTime = System.currentTimeMillis();
    }

    public String getClientId() {
        return clientId;
    }

    public Channel getChannel() {
        return channel;
    }

    public long getRegisterTime() {
        return registerTime;
    }

    public long getLastActiveTime() {
        return lastActiveTime;
    }

    public void updateLastActiveTime() {
        this.lastActiveTime = System.currentTimeMillis();
    }

    @Override
    public String toString() {
        return "ClientInfo{" +
                "clientId='" + clientId + '\'' +
                ", registerTime=" + registerTime +
                ", lastActiveTime=" + lastActiveTime +
                '}';
    }
}